package homework.homework9;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class Text3 implements Runnable {
    private Socket socket;

    public Text3(Socket socket) {
        this.socket = socket;
    }

    @Override
    public void run() {
        try {
            InputStream in = socket.getInputStream();
            StringBuilder builder = new StringBuilder();
            char pre = 'a', cur = 'a';
            int d;
            while ((d = in.read()) != -1) {
                cur = (char) d;
                if (pre==13&&cur==10){
                    break;
                }
                builder.append(cur);
                pre = cur;
            }
            System.out.println(builder);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
